<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    li{
      list-style: none;
    }
    .box{
      display: flex;
      flex-wrap: wrap;
      width: 540px;
      margin: 10px auto;
      gap: 10px;
    }
    .box li{
      width: 100px;
      height: 100px;
    }
    .box li img{
      width: 100px;
      height: 100px;
      border: 2px solid #258DF2;
      box-sizing: border-box;
      border-radius: 50%;
      transition: all 0.2s ease-in-out;
    }
    .box li img:hover{
      box-shadow: 0px 0px 10px 3px rgb(218, 159, 48);
    }
  </style>
</head>
<body>
  <ul class="box">
    <script>
      let arr = [
        `./images/1.webp`,
        `./images/2.webp`,
        `./images/3.webp`,
        `./images/4.webp`,
        `./images/5.webp`,
        `./images/6.webp`,
        `./images/7.webp`,
        `./images/8.webp`,
        `./images/9.webp`,
        `./images/10.webp`,
        `./images/11.webp`,
        `./images/12.webp`,
        `./images/13.webp`,
        `./images/14.webp`,
        `./images/15.webp`,
        `./images/16.webp`,
        `./images/17.webp`,
        `./images/18.webp`,
        `./images/19.webp`,
        `./images/20.webp`,
      ]
      let name = [
        `金蝉`,
        `海月`,
        `戈娅`,
        `桑启`,
        `暃`,
        `云缨`,
        `艾琳`,
        `司空震`,
        `澜`,
        `夏洛特`,
        `阿骨朵`,
        `镜`,
        `蒙犽`,
        `西施`,
        `曜`,
        `瑶`,
        `猪八戒`,
        `上官婉儿`,
        `沈梦溪`,
        `伽罗`,
        `海月`,
      ]
      let num = 0
      while(1){
        num = +prompt(`请输入显示的英雄个数1~20之间:`)
        if(num < 1 && num > 20){
          alert(`输入非法，请重新输入:`)
        } else{
          break
        }
      }
      for(let i = 0; i < num; i++){
        document.write(`
        <li>
          <img src="${arr[i]}" alt="${name[i]}">
        </li>
        `)
      }
    </script>
  </ul>
</body>
</html>